<?php

namespace App\Http\Requests\customer;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait PriceRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
//            'name' => 'required',
            'customer_id' => 'required',
//            'route_id' => 'required',
            'route_id' => 'required',
            'goods_attr' => 'required',
            'currency_id' => 'required',
            'line_price' => 'required',

        ], [
            'name.required' => '请填写报价名称',
            'customer_id.required' => '请选择大客户',
//            'route_id.required' => '请选择航线',
            'route_id.required' => '请选择目的地',
            'goods_attr.required' => '请选择属性',
            'currency_id.required' => '请选择币种',
            'line_price.required' => '请填写国际干线费',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
